import { getDepartments, getDoctorListApi } from "../../utils/api";

const departments = {
  state() {
    return {
      department: "",
      doctorli: [],
    };
  },
  mutations: {
    // 请求科室列表
    departmentsApi(state, payload) {
      state.department = payload.data;
    },
    // 请求医生列表
    chooseitem(state, payload) {
      state.doctorli = payload.data;
      // console.log(state.doctor);
    },
  },
  actions: {
    // 科室列表
    async departmentsApi({ commit }) {
      const res = await getDepartments();
      commit("departmentsApi", { data: res.result });
    },
    // 医生列表
    async getdoctor({ commit }, payload) {
      const res = await getDoctorListApi({ ksid: payload.id });
      // console.log(res.result);
      commit("chooseitem", { data: res.result });
    },
  },
};
export default departments;
